(function() {
  var $, MembershipController, TomatoBreak, exports;
  var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    function ctor() { this.constructor = child; }
    ctor.prototype = parent.prototype;
    child.prototype = new ctor;
    child.__super__ = parent.prototype;
    return child;
  }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  exports = this;
  $ = jQuery;
  TomatoBreak = exports.TomatoBreak;
  MembershipController = (function() {
    __extends(MembershipController, TomatoBreak.FormController);
    function MembershipController() {
      MembershipController.__super__.constructor.apply(this, arguments);
      TomatoBreak[this.modelName].bind('error', __bind(function(model, errors) {
        return this.showErrors(errors);
      }, this));
    }
    MembershipController.prototype.submit = function(event) {
      var model;
      event.preventDefault();
      model = new TomatoBreak[this.modelName](this.form.serializeForm());
      model.bind('ajaxSuccess', __bind(function(record, status, xhr) {
        var response;
        if (xhr.responseText) {
          response = JSON.parse(xhr.responseText);
        }
        if ((response != null ? response.errors : void 0) != null) {
          return model.trigger('error', model, response != null ? response.errors : void 0);
        } else {
          return exports.location = 'dashboard/#!/';
        }
      }, this));
      return model.save();
    };
    return MembershipController;
  })();
  TomatoBreak.MembershipController = MembershipController;
}).call(this);
